//
//  UIScrollView+Extension.m
//  AutoShowView
//
//  Created by 冷悦 on 16/2/1.
//  Copyright © 2016年 冷悦. All rights reserved.
//

#import "UIScrollView+Extension.h"

@implementation UIScrollView (Extension)

- (void)removeAllSubViews{
    NSArray *views = self.subviews;
    
    for (UIView *view in views) {
        if (view.tag == kScrollViewCustomItemViewTag) {
            [view removeFromSuperview];
        }
    }
}

- (NSArray *)getContentViews{
    NSMutableArray *views = [NSMutableArray array];
    CGFloat width = self.frame.size.width;
    CGFloat height = self.frame.size.height;
    CGPoint offset = self.contentOffset;
    CGRect contentFrame = CGRectMake(offset.x, offset.y, width, height);
    NSArray *subViews = self.subviews;
    
    for (UIView *view in subViews) {
        CGRect viewFrame = view.frame;
        BOOL isFrameOverlap = CGRectIntersectsRect(viewFrame, contentFrame);
        
        if (isFrameOverlap == YES) {
            [views addObject:view];
        }
    }
    
    return views;
}

@end
